package define;

import main.ErrorException;
import code.BaseOut;
import code.CppOut;
import code.FlexOut;
import code.JavaOut;

public enum CodeOut 
{
	E_JAVA_CO("java"),
	E_CPP_CO("cpp"),
	E_FLEX_CO("flex"),
	;
	
	private String m_lang;
	
	private CodeOut(String lang)
	{
		m_lang = lang;
	}
	
	public BaseOut getOut(boolean isAllowSet, String nameSpace) throws ErrorException
	{
		switch (this)
		{
		case E_JAVA_CO:
			return new JavaOut(isAllowSet, nameSpace);
		case E_CPP_CO:
			return new CppOut(isAllowSet, nameSpace);
		case E_FLEX_CO:
			return new FlexOut(isAllowSet, nameSpace);
		default:
			return null;
		}
	}
	
	public static CodeOut getCodeOut(String lang)
	{
		for(CodeOut co: CodeOut.values())
		{
			if(co.m_lang.compareTo(lang) == 0)
			{
				return co;
			}
		}
		return null;
	}
}
